package com.by.controller;

import com.by.service.SmsService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
@Api
public class SmsController {
    @Autowired
    SmsService smsService;
    @PostMapping("/sms")
    public void sendCode(@RequestParam String phoneNumber) {
        // 生成随机验证码
        String code = String.valueOf((int) ((Math.random() * 9 + 1) * 100000));
        //由于这是使用的阿里云通过的测试短信发送服务，所以这里的手机号需要在阿里云短信服务中配置绑定
        smsService.sendCode(phoneNumber, code);
    }

}
